package com.qmgyl.marketshop.api;


import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.qmfresh.service.order.facade.dto.OrderQuery;
import com.qmgyl.marketshop.common.HttpUtils;
import com.qmgyl.marketshop.vo.ListWithPage;
import com.qmgyl.marketshop.vo.OrderListResult;
import com.qmgyl.marketshop.vo.ServiceResult;

public class OrderServiceApi {
	
	private String serviceUrl;
	
	
	public String getServiceUrl() {
		return serviceUrl;
	}

	public void setServiceUrl(String serviceUrl) {
		this.serviceUrl = serviceUrl;
	}

	/**
	 * 获取订单列表
	 * @param orderQuery
	 * @return
	 */
	public ListWithPage<OrderListResult> getList(OrderQuery orderQuery){
		String result = HttpUtils.postRequestBody(serviceUrl + "/order/list",orderQuery);
		System.out.println(result);
		ServiceResult<ListWithPage<OrderListResult>> sr = JSONObject.parseObject(result, new TypeReference<ServiceResult<ListWithPage<OrderListResult>>>(){});
		return sr.getBody();
	}
	/**
	 * 取消订单
	 * @param orderQuery
	 * @return
	 */
	public String cancelOrder(OrderQuery orderQuery){
		String result = HttpUtils.postRequestBody(serviceUrl + "/order/cancelOrder",orderQuery);
		System.out.println(result);
		return result;
	}

}
